import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName LC2085
 * @Author ykx
 * @Date 2024/3/23 15:59
 * @Version 1.0
 */
public class LC2085 {
    public int countWords(String[] words1, String[] words2) {
        int count = 0;
        Map<String, Integer> map1 = new HashMap<>();
        Map<String, Integer> map2 = new HashMap<>();
        for (String s : words1) {
            map1.put(s, map1.getOrDefault(s, 0) + 1);
        }
        for (String s : words2) {
            map2.put(s, map2.getOrDefault(s, 0) + 1);
        }
        for (String s : words1) {
            if (map1.getOrDefault(s, 0)==1&&map2.getOrDefault(s, 0)==1) {
                count++;
            }
        }

        return count;
    }
}
